home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Caml Light 0.61 / Source / src / compiler / primdecl.ml < prev    next >
Encoding:
Text File  |  1993-09-24  |  2.1 KB  |  78 lines  |  [TEXT/MPS ]

  1. (* Concrete syntax for primitive declarations *)
  2.  
  3. #open "prim";;
  4. #open "globals";;
  5.  
  6. let primitive_names = [
  7.   "identity", Pidentity;
  8.   "field0", Pfield 0;
  9.   "field1", Pfield 1;
  10.   "field2", Pfield 2;
  11.   "field3", Pfield 3;
  12.   "setfield0", Psetfield 0;
  13.   "setfield1", Psetfield 1;
  14.   "setfield2", Psetfield 2;
  15.   "setfield3", Psetfield 3;
  16.   "update", Pupdate;
  17.   "tag_of", Ptag_of;
  18.   "raise", Praise;
  19.   "not", Pnot;
  20.   "succ", Psuccint;
  21.   "pred", Ppredint;
  22.   "~int", Pnegint;
  23.   "+int", Paddint;
  24.   "-int", Psubint;
  25.   "*int", Pmulint;
  26.   "div", Pdivint;
  27.   "mod", Pmodint;
  28.   "and", Pandint;
  29.   "or", Porint;
  30.   "xor", Pxorint;
  31.   "shift_left", Pshiftleftint;
  32.   "shift_right_signed", Pshiftrightintsigned;
  33.   "shift_right_unsigned", Pshiftrightintunsigned;
  34.   "incr", Pincr;
  35.   "decr", Pdecr;
  36.   "int_of_float", Pintoffloat;
  37.   "float_of_int", Pfloatprim Pfloatofint;
  38.   "~float", Pfloatprim Pnegfloat;
  39.   "+float", Pfloatprim Paddfloat;
  40.   "-float", Pfloatprim Psubfloat;
  41.   "*float", Pfloatprim Pmulfloat;
  42.   "/", Pfloatprim Pdivfloat;
  43.   "string_length", Pstringlength;
  44.   "get_nth_char", Pgetstringchar;
  45.   "set_nth_char", Psetstringchar;
  46.   "make_vect", Pmakevector;
  47.   "vect_length", Pvectlength;
  48.   "get_vect_item", Pgetvectitem;
  49.   "set_vect_item", Psetvectitem;
  50.   "==", Ptest Peq_test;
  51.   "!=", Ptest Pnoteq_test;
  52.   "=int", Ptest (Pint_test PTeq);
  53.   "<>int", Ptest (Pint_test PTnoteq);
  54.   "<int", Ptest (Pint_test PTlt);
  55.   ">int", Ptest (Pint_test PTgt);
  56.   "<=int", Ptest (Pint_test PTle);
  57.   ">=int", Ptest (Pint_test PTge);
  58.   "=float", Ptest (Pfloat_test PTeq);
  59.   "<>float", Ptest (Pfloat_test PTnoteq);
  60.   "<float", Ptest (Pfloat_test PTlt);
  61.   ">float", Ptest (Pfloat_test PTgt);
  62.   "<=float", Ptest (Pfloat_test PTle);
  63.   ">=float", Ptest (Pfloat_test PTge);
  64.   "=string", Ptest (Pstring_test PTeq);
  65.   "<>string", Ptest (Pstring_test PTnoteq);
  66.   "<string", Ptest (Pstring_test PTlt);
  67.   ">string", Ptest (Pstring_test PTgt);
  68.   "<=string", Ptest (Pstring_test PTle);
  69.   ">=string", Ptest (Pstring_test PTge)
  70. ];;
  71.  
  72. let find_primitive arity name =
  73.   try
  74.     ValuePrim(arity, assoc name primitive_names)
  75.   with Not_found ->
  76.     ValuePrim(arity, Pccall(name, arity))
  77. ;;
  78.